package com.ct.order.enums;

/**
 * 订单状态枚举类
 *
 * 10=未付款 20=待处理 30=待自取(已处理) 40=待配送(已处理) 50=已配送 60=已完成
 * 70=售后处理中 80=售后处理完成 90=已取消(未支付) 100=已取消(已支付)
 */
public enum OrderStatus {

    UNPAID(          1,"未付款"),
    WAIT_PROCESSED(  2,"待处理"),
    TAKE_BY_ONESELF( 3,"待自取"),
    PENDING_DELIVERY(4,"待配送"),
    DELIVERED(       5,"已配送"),
    COMPLETED(       6,"已完成"),
    AFTER_SALES_PROCESSING(70,"售后处理中"),
    AFTER_SALES_COMPLETED( 80,"售后处理完成"),
    CANCELED_UNPAID(       90,"已取消(未支付)"),
    CANCELED_PAID(         100,"已取消(已支付)");


    private final Integer code;
    private final String desc;

    OrderStatus(int code, String desc){
        this.code = code;
        this.desc = desc;
    }


    public static OrderStatus getByCode(Integer code) {
        for (OrderStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }


    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


}
